<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <title><spring:message code="pattern.maiduan"></spring:message></title>
     <link href="${pageContext.request.contextPath }/phone/css/cssfolder/cssstyle/stylefloder.css" rel="stylesheet" type="text/css" />  
    <link href="${pageContext.request.contextPath }/phone/css/xiadan.css" rel="stylesheet" />

</head>
<body>
    <div>
        <!--头部--有分类-->
        <div class="cate_header">
            <div class="putong_top">
                <a href="javascript:history.go(-1);"></a>
                <div><spring:message code="pattern.maiduan"></spring:message></div>
            </div>
        </div>
        <div role="main" class="main" style="background:#F0F0F2;padding-bottom:0px;">
        <div style="padding:20px;font-size:14px;line-height:22px;">
         ${helpCenter.hContent }
        </div>
            
            <!--工艺-->
            <div class="gongyi">
                <p><spring:message code="pattern.buyout"></spring:message> <span class="ri">${pattern.pBuyoutPrice }<spring:message code="yuan"></spring:message></span></p>
                
            </div>

            <!--数量、购买-->
            <div class="shu_buy" style="height:40px;padding:0;">
                <div class="shu_btn" style="margin-top:0px;">
                    <a href="javascript:add(2);"><spring:message code="pattern.join"></spring:message></a>
                    <a href="javascript:add(1);"><spring:message code="pattern.buy"></spring:message></a>
                    <div class="clr"></div>
                </div>
            </div>

        </div>
        

   </div>
    <form method="post" action="${pageContext.request.contextPath}/api/orders/viewinsertorders" id="form">
	<input type="hidden" id="pId" name="pId" value="${pattern.pId }">
	<input type="hidden" id="ppId" name="ppId">
	<input type="hidden" id="fId" name="fId">
	<input type="hidden" id="size" name="size" value="1">
	<input type="hidden" id="status" name="status" value="1">
	
	</form>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/layer_mobile/layer.js"></script>
<script type="text/javascript">
function add(statu){
	
	if(statu==1){
	
	$.ajax({
			 url:'${pageContext.request.contextPath }/web/orders/chakanhuaxing',
			 async : false,
			 data: {"pId":"${pattern.pId }"},
			 type : "GET", 
			 success :function(result){
			 if(result == "SUCCESS"){
				$("#form").submit();
			 }else{//失败
				 layer.open({content: '<spring:message code="pattern.beenBought"></spring:message>',skin: 'msg',time: 1});
	   	   	   		
			 }
			 }
			 });
	}else{
		$.ajax({
			 url:'${pageContext.request.contextPath }/web/shoppingcart/insertshoppingcart',
			 async : false,
			 data:$("#form").serialize() ,
			 type : "POST", 
			 success :function(result){
			 var status=result.msg.status;
			 var desc=result.msg.desc;
			 if(status == 0){
				 layer.open({content: '<spring:message code="pattern.success"></spring:message>',skin: 'msg',time: 1});
	   	   	   		
			 }else if(status == 2){//失败
				 layer.open({content: '<spring:message code="pattern.fail"></spring:message>',skin: 'msg',time: 1});
	   	   	   		
			    }else if(status ==1){//被买断
			    	layer.open({content: '<spring:message code="pattern.beenBought"></spring:message>',skin: 'msg',time: 1});
	   	   	   		
			    }else if(status ==3){//被买断
			    	layer.open({content: '<spring:message code="pattern.noLogin"></spring:message>',skin: 'msg',time: 1});
	   	   	   		
			    }
			 }
			 });
	}
	
}
</script>
</body>
</html>
